##parameters=assessmentIdentity, componentIdentity, readOnly=False

component  = context.getComponentByIdentity( componentIdentity )

if not component:
    raise "Could not find component %s" % componentIdentity

model      = component.getModel()
assessment = model.loadAssessment( assessmentIdentity )

if readOnly:
    return """
        <div class="field">
            <label>%s</label>
            <div>%s</div>
        </div>
    """ %  ( (component.getContent() or component.title_or_id()), assessment.getComponentByIdentityValue( componentIdentity ) )
    
    


if not assessment:
    raise "Could not find assessment %s on model %s" % ( assessmentIdentity, model.title_or_id() )

request = context.REQUEST

request.set("ASSESSMENT", assessment)



#request["ASSESSMENT_OPENEDFROM"] = assessment.getOpenedFromRepositoryIdentity()
#request['ASSESSMENT_REVISION'] = assessment.createNewRevision( userIdentity )
#request["REFRESH_JAVASCRIPT"] = []
request.set("DECLARATIONS_JAVASCRIPT", {})     #a dictionary (set) to prevent individual component types duplicating declarations
request.set("REFRESH_JAVASCRIPT", [])     #a dictionary (set) to prevent individual component types duplicating declarations
request.set("ONLOAD_JAVASCRIPT", {})           #a dictionary (set) to prevent individual component types duplicating onload statements
request.set("ISPREVIEW", True)

return component.renderAssessmentEditor( request )



